import numpy as np
import pandas as pd

filepath = "E:\\0S-lab\\0slab项目\\10襄阳\\multicenter\\out\\DBSCAN_100_20\\"
filenames = ["all2008out.csv", "all2015out.csv", "all2017out.csv"]

for i in filenames:
    f = open(filepath + i)
    tb = pd.read_csv(f)
    f.close()

    # cluster
    pt = pd.pivot_table(tb, index= "cluster", values= ["id","x","y"],aggfunc = {"x":'mean',"y":'mean', "id": 'count'})
    pt.reset_index(inplace=True)
    pt.rename(columns = {"id":"count"}, inplace = True)
    pt["area"] = pt["count"] * 900 /10000
    pt.to_csv(filepath + i.split(".csv")[0] + "_cluster.csv", index=None)


